package com.xlhj.elastic.controller;

import com.xlhj.elastic.common.ResultData;
import com.xlhj.elastic.entity.SysUser;
import com.xlhj.elastic.service.EsUserService;
import com.xlhj.elastic.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: liucaijing
 * @description: 用户信息控制器
 * @date: 2021/5/11 15:22
 */
@RestController
@RequestMapping("/elastic/user")
public class UserController {

    @Autowired
    private SysUserService userService;
    @Autowired
    private EsUserService esUserService;

    @PostMapping("/saveUserInfo")
    public ResultData saveUserInfo(@RequestBody SysUser user) {
        boolean saveFlag = userService.save(user);
        if (saveFlag) {
            esUserService.saveEsUser(user);
        }
        return ResultData.ok();
    }
}
